﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MapReduce.Services
{
    public class ExecuteReduceService : ExecuteJobService
    {
        public override byte[][] InnerExecute(Object pJobObj, byte[][] pData)
        {
            String key = U.Convert(pData[3]).ToString();
            List<String> valList = (List<String>)U.Deserialize(pData[4]);

            IReduce reduce = ((IReduce)pJobObj);

            IEnumerable<KeyValuePair<String, String>> tmpMapOutput = reduce.Execute(key, valList);

            return new byte[][] { U.Serialize(tmpMapOutput) };

        }

    }
}








/*
public byte[][] Execute(byte[][] pData)
{
    /*
    MapReduce.MapReduce_Old.ReduceMethod reduce = (MapReduce.MapReduce_Old.ReduceMethod)U.Deserialize(pData[0]);
    String key = U.Convert(pData[1]).ToString();
    List<String> valList = (List<String>)U.Deserialize(pData[2]);

    IEnumerable<KeyValuePair<String, String>> tmpMapOutput = reduce(key, valList);

    return new byte[][] { U.Serialize(tmpMapOutput) };
             
    return null;
}*/